function noisedetect = ecgnoise(data, Real_HR)
% initialize index2 for time-position looping
index2 = 1;
% get noise time position
time_noise = zeros(length(Real_HR),1);
for index = 1:length(Real_HR)
    if Real_HR(index) > 250 || Real_HR(index) < 35
        time_noise(index2) = index;
        index2 = index2 + 1;
    end
end
t = (0:length(data)-1)/553.6;
plot(t,data,'r',time_noise(1:length(time_noise)),zeros(length(time_noise),...
     1),'g');

        
% reconstruction of time_noise to real-time
%time_noise_real = round(time_noise .* 553.6);

